package com.mbcn.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.mbcn.dao.MemberDAO;
import com.mbcn.dao.impl.MemberDAOImpl;
import com.mbcn.model.Member;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class MemberAction extends ActionSupport implements ModelDriven {
	Member member = new Member();
	MemberDAO memberDAO = new MemberDAOImpl();
	HttpServletRequest request = ServletActionContext.getRequest();

	public Object getModel() {
		return member;
	}

	public String loadInfo() throws Exception {
		member = memberDAO.loadInfo(member.getMemberId());
		return SUCCESS;
	}

	public String updateInfo() throws Exception {
		member = memberDAO.updateInfo(member);
		return SUCCESS;
	}

	public String changePassword() throws Exception {
		String oldPassword = request.getParameter("oldPassword");
		String password = request.getParameter("password");
		String passwordRetype = request.getParameter("passwordRetype");
		member = memberDAO
				.changePassword(oldPassword, password, passwordRetype);
		return SUCCESS;
	}

	// public String updateInfo() throws Exception {
	// try {
	// itemList = itemsDAO.listItemByCategory(item.getItemCategory());
	// } catch (Exception e) {
	// e.printStackTrace();
	// }
	// return SUCCESS;
	//
	// }

}
